/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sudoku;

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.*;

public class KeyEventDemo extends JApplet implements KeyListener, ActionListener {
    JTextField displayArea;
    JTextField typingArea;

    public void init() {
    typingArea = new JTextField(20);
    typingArea.addKeyListener(this);
    displayArea = new JTextField(20);
    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(typingArea, BorderLayout.NORTH);
    contentPane.add(displayArea, BorderLayout.CENTER);
    setContentPane(contentPane);
    }
    
    public void keyPressed(KeyEvent e) {
    displayInfo(e);
    }
    
    protected void displayInfo(KeyEvent e){
    int keyCode = e.getKeyCode();
    String keyText = e.getKeyText(keyCode);
    displayArea.setText(keyText);
    }

    public void keyTyped(KeyEvent e) {}
    public void keyReleased(KeyEvent e) {}
    public void actionPerformed(ActionEvent e) {}  
}
